package com.anli.service;

import org.apache.curator.RetryPolicy;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.retry.ExponentialBackoffRetry;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author: LCG
 * 作者: LCG
 * 日期: 2021/3/9  14:33
 * 描述:
 */
@Configuration
public class ZkCOnfig {


   // @Bean
    public CuratorFramework getZkCurator(){
        //获取锁
        RetryPolicy retryPolicy=new ExponentialBackoffRetry(2000,3);
        //创建客户端
        CuratorFramework curatorFramework = CuratorFrameworkFactory.newClient("127.0.0.1", retryPolicy);
        //启动客户端
        curatorFramework.start();
        return curatorFramework;
    }

}
